import { Vec3 } from "cc";
import { ecs } from "db://app-game/libs/ecs/ECS";

/** 摇杆控制信息组件 */
@ecs.register("JoysitickControl")
export class JoysitickControlComp extends ecs.Comp {
  /** */
  _active: boolean = false;
  /** 激活 */
  get active(): boolean {
    this._active = this.input.length() > 0;
    return this._active;
  }

  /** 输入向量 */
  input: Vec3 = Vec3.ZERO;
  /** 摇杆长度 */
  stickLength: number = 0;
  /** 禁用 */
  disable: boolean = false;
  /** 冷却 */
  coolingTime: number = 0;
  /** 冷却状态 */
  coolingState: boolean = false;

  reset(entity: ecs.Entity): void {
    this._active = false;
    this.input = Vec3.ZERO;
    this.stickLength = 0;
    this.disable = false;
    this.coolingTime = 0;
    this.coolingState = false;
  }
}
